package game.games.sky;

import game.AbstractGame;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Sky extends AbstractGame
{
    private static Sky instance;
    
    public synchronized static Sky getInstance()
    {
        if (instance == null)
        {
            instance = new Sky();
        }
        return instance;
    }
    
    public Sky()
    {
        super(false);
    }
    
    @Override
    public void render(Graphics g)
    {
        if (isRunning())
        {
            try
            {
                Dimension size = getFrameSize();
                BufferedImage img = ImageIO.read(getClass().getResourceAsStream("sky.gif"));
                for (int x = 0; x < 1 + size.getWidth()  / img.getWidth(); x++)
                {
                    for (int y = 0; y < 1 + size.getHeight() / img.getHeight(); y++)
                    {
                        g.drawImage(img, x * img.getWidth(), y * img.getHeight(), null);
                    }
                }
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            
        }
    }

    @Override
    protected void doNext()
    {
        // TODO Auto-generated method stub
        
    }
    
    public static void main(String[] args)
    {
        Thread t = new Thread(Sky.getInstance(), "Sky");
        t.start();
    }
}
